Installing and Upgrading PowerShell 7 on Windows
TLDR
- Windows PowerShell (5.1) and PowerShell 7 are completely different products; both can coexist on the same system.
- PowerShell 7 uses UTF-8 (without BOM) encoding, which effectively resolves character encoding issues when interacting with Chinese characters and Git in older versions.
- Installation is recommended when you need cross-platform scripts, use AI-generated scripts, or when tools explicitly require PowerShell 6+.
- After installing PowerShell 7, you must run the
Update-Helpcommand to obtain the complete offline documentation. - Use WinGet for quick installation and version upgrades.
Differences between Windows PowerShell and PowerShell 7
When you might encounter this: When you find that the built-in PowerShell cannot run modern tools (such as Copilot CLI) or displays garbled text when handling Chinese characters.
- Underlying Architecture: Windows PowerShell is based on the closed-source .NET Framework and is limited to Windows; PowerShell 7 is based on open-source .NET and supports cross-platform execution.
- Lifecycle: Windows PowerShell has ceased new feature development and only receives maintenance updates.
- Default Encoding: PowerShell 7 uses UTF-8 (without BOM) by default, solving the garbled text issues encountered in older versions when handling plain text files and Chinese characters.
- Executable Isolation: Both can coexist; the Windows PowerShell executable is
powershell.exe, while PowerShell 7 ispwsh.exe.
Installation Guide
When you might encounter this: When you need to install or upgrade PowerShell 7 to meet development environment requirements.
WinGet automatically configures environment variables after installation, so no manual configuration is required.
- Search for available versions:powershell
winget search --id Microsoft.PowerShell - Install the latest stable version:powershell
winget install --id Microsoft.PowerShell --source winget - Upgrade to the latest version with one click:powershell
winget upgrade --id Microsoft.PowerShell - Uninstall:powershell
winget uninstall --id Microsoft.PowerShell
Get-Help Documentation Mechanism
When you might encounter this: When you run Get-Help but find that you cannot view examples or detailed parameter descriptions; this is because PowerShell does not bundle offline documentation by default.
If you need complete example documentation, you can use the following methods:
- Online Query: Use the
-Onlineparameter (e.g.,Get-Help Get-Process -Online) to open the official web-based documentation directly in your browser. - Download Offline Files: Run the following command as an administrator:powershell
Update-Help -UICulture zh-tw, en-US -Force -ErrorAction SilentlyContinue
Parameter Explanation
-UICulture zh-tw, en-US: Specifies the download language, addingen-USas a fallback.-Force: Forces a re-download of the help files.-ErrorAction SilentlyContinue: Ignores error messages generated by modules that do not provide online help files.
When is an additional installation of the new version required?
When you might encounter this: When you are hesitant about whether to remove the old version or install the new one.
- AI Script Baseline: AI-generated scripts are mostly based on PowerShell 6+, and they often fail when executed in older versions.
- Encoding Issues: Resolves the issue where Windows PowerShell 5.1 misidentifies UTF-8 without BOM files as ANSI.
- Tool Compatibility: Modern development tools like Copilot CLI explicitly require PowerShell 6+.
- Cross-Platform Requirements: If you need to write scripts that are compatible with Windows, Linux, and macOS.
TIP
Both can coexist; there is no need to remove Windows PowerShell.
Change Log
- 2026-03-25 Initial documentation created.
